 var equipInfoTableInit = function(){
    var oTableInit = new Object();
    //初始化Table
    oTableInit.Init = function () {
        $('#equipInfoTable').bootstrapTable({
            url: ctx +'/equipment/account/listEquipInfoByFilter/get.mvc',         //请求后台的URL（*）
            method: 'get',                      //请求方式（*）
//            toolbar: '#toolbar',                //工具按钮用哪个容器
            striped: true,                      //是否显示行间隔色
            cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
            pagination: true,                   //是否显示分页（*）
            paginationLoop:false,
            sortable: true,                     //是否启用排序
            sortOrder: "asc",                   //排序方式
            queryParams: oTableInit.queryParams,//传递参数（*）
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber:1,                       //初始化加载第一页，默认第一页
            pageSize: 10,                       //每页的记录行数（*）
            pageList: [10, 25, 50, 100],        //可供选择的每页的行数（*）
            search: false,                       //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
            strictSearch: true,
            showColumns: false,                  //是否显示所有的列
            showRefresh: false,                  //是否显示刷新按钮
            minimumCountColumns: 2,             //最少允许的列数
            clickToSelect: true,                //是否启用点击选中行
            height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
            uniqueId: "pkId",                     //每一行的唯一标识，一般为主键列
            showToggle:false,                    //是否显示详细视图和列表视图的切换按钮
            cardView: false,                    //是否显示详细视图
            detailView: false,                   //是否显示父子表
            singleSelect:false,                    //禁止多选
            checkboxHeader:true,                 //列头取消多选
            columns: [
                {
                    radio:true,
                    align : 'center',
                    valign : 'middle'
                },
                {
                    title: '序号',
                    align : 'center',
                    valign : 'middle',
                    formatter : function (value, row, index){
                        var options = $('#equipInfoTable').bootstrapTable('getOptions');
                        return options.pageSize * (options.pageNumber - 1) + index + 1;
                    }
                },
                {
                    field: 'equipCode',
                    title: '设备编号',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'

                }, {
                    field: 'equipName',
                    title: '设备名称',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'equipModel',
                    title: '设备型号',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'equipType',
                    title: '设备类别',
                    sortable:false,
                    align : 'center',
                    valign : 'middle',
                    formatter : function (value, row, index){
                    	if(value=='1'){
                    		return '生产类';
                    	}
                    	if(value=='2'){
                    		return '环境类';
                    	}
                    	if(value=='3'){
                    		return '能源类';
                    	}
                    	if(value=='4'){
                    		return '检测类';
                    	}
                    	if(value=='5'){
                    		return '生产辅助类';
                    	}
                    	
                    }
                }, {
                    field: 'operation',
                    title: '所属工序',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'aidEquips',
                    title: '辅助设备',
                    sortable:false,
                    align : 'center',
                    valign : 'middle',
                    formatter : function(value, row, index){
                    	var html="";
                    	for(var i =0 ;i<value.length;i++){
                    		html+=value[i].aidEquipName+","
                    	}
                    	return html.substring(0,html.length-1);
                    }
                }, {
                    field: 'supplier',
                    title: '供应商',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'factoryName',
                    title: '厂区',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'lineName',
                    title: '产线',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'shopName',
                    title: '车间',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'areaName',
                    title: '区域',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'installLocation',
                    title: '安装位置',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                }, {
                    field: 'responsiblePerson',
                    title: '责任人',
                    sortable:false,
                    align : 'center',
                    valign : 'middle'
                },{
                    field: 'pkId',
                    title: 'pkId',
                    visible:false
                },{
                    field: 'equipId',
                    title: 'equipId',
                    visible:false
                }]

        });
    };
    //得到查询的参数
    oTableInit.queryParams = function (params) {
        return {   // 这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            size: params.limit,   // 页面大小
            num: (params.offset/params.limit) + 1,  // 页码
            sort: params.sort,
            order: params.order,
            equipCode: $("#equipCode").find("option:selected").text(),
            equipName: $("#equipName").val(),
            operationId: $("#operation").val(),
            supplier:$("#supplier").val()
        };
    };
    return oTableInit;
};

jQuery(document).ready(function() {
    //1.初始化Table
    var oTable = new equipInfoTableInit();
    oTable.Init();
    //初始化页面
    equipInfoInit.init();
});

var equipInfoInit = function() {
    return {
        init:function() {
            SystemCommon.getQueryEquipCode();
            SystemCommon.getQueryOperation();
            SystemCommon.getSysDict("EQUIP_TYPE","equipType");
            equipInfoInit._initDate();
            equipInfoInit._query();
            equipInfoInit._keyQuery();
            equipInfoInit._reset();
            equipInfoInit._refresh();
            equipInfoInit._initFactorySelect();
            equipInfoInit._initLineSelect();
            equipInfoInit._initShopSelect();
            equipInfoInit._initAreaSelect();
            equipInfoInit._initEquipTypeChange();
            equipInfoInit._accountRegister();
            equipInfoInit._validatorForm();
            equipInfoInit._save();
            equipInfoInit._modalHidden();
        },
        _initDate : function(){
        	$('.productionDate').val(new Date().format('yyyy-MM-dd'));
			$('.productionDate').datetimepicker({
				format : 'yyyy-mm-dd',
				language : 'zh-CN',
				pickerPosition: "bottom-left",
				/*endDate : new Date().format('yyyy-MM-dd'),*/
				forceParse : true,
				startView :2,
				autoclose:true,
				minView:2,
				todayBtn:true
			}).on('hide',function(event){
				event.preventDefault();
				event.stopPropagation();
			});
        },
        
        //条件查询
        _query:function() {
            $("#queryEquip").on("click",function(){
                $('#equipInfoTable').bootstrapTable('refreshOptions',{
                    pageNumber:1
                });
            });
        },
        //按键查询
        _keyQuery:function() {
            $(".equipQuery").keypress(function (e) {
                if (e.which === 13) {
                    $("#queryEquip").trigger("click");
                }
            });
        },
        //重置查询
        _reset:function() {
            $(".reset").on("click",function(){
                $(".clearfix input").val("");
                //重置select2选择框
                $('.queryEquipment').val(null).trigger("change");
                $('.operationSearch').val(null).trigger("change");
            });
        },
        _refresh : function(){
            //刷新
            $("#refreshTable").on("click",function(){
                $('#equipInfoTable').bootstrapTable('refresh');
            });
        },
        //台账登记
        _accountRegister:function() {
            $("#accountRegister").on('click', function(e) {
                e.preventDefault();
                var codes = $.map($('#equipInfoTable').bootstrapTable('getSelections'), function (row) {
                    return row.equipCode;
                });
                if (codes.length !== 1 ) {
                    DialogUtil.warning("请选择需要台账登记的记录！");
                    return;
                }
                var userSelect2 = SystemCommon.getSystemUser();
                //解决select2无法输入问题
                $.fn.modal.Constructor.prototype.enforceFocus = function() {
                    $("#myModal select[name='responsiblePerson']").focus();
                };
                $.ajax({
                    url: ctx+"/equipment/account/getEquipInfoByCode/get.mvc",
                    type: "post",
                    dataType: "json",
                    data: {equipCode: codes.toString()},
                    success :function(response) {
                        console.log(response);
                        if(response.data) {
                            var _data = response.data;
                            // language=JQuery-CSS
                            $("#accountRegisterForm").find("input[name=equipCode]").val(_data.equipCode);
                            $("#accountRegisterForm").find("input[name=equipName]").val(_data.equipName);
                            $("#accountRegisterForm").find("input[name=supplier]").val(_data.supplier);
                            $("#accountRegisterForm").find("input[name=operation]").val(_data.operation);
                            $("#accountRegisterForm").find("input[name=equipModel]").val(_data.equipModel);
                            
                        	$(".aidEquipCodes").attr("disabled",false);
                        	$(".effectiveWorkTime").attr("disabled",false);
                            if(_data.equipType=='1'){
                            	$("#accountRegisterForm").find("input[name=equipType]").val('生产类');
                            	$('.line').addClass('form-required', 'form-required-4');
                            	$('.shop').addClass('form-required', 'form-required-4');
                                $("#accountRegisterForm .shop").addClass("form-required");
                                $("#accountRegisterForm").bootstrapValidator("addField","shop",{
                                    validators: {
                                        notEmpty: {
                                            message: '车间不能为空'
                                        }
                                    }
                                });
                                $("#accountRegisterForm .line").addClass("form-required");
                                $("#accountRegisterForm").bootstrapValidator("addField","line",{
                                    validators: {
                                        notEmpty: {
                                            message: '产线不能为空'
                                        }
                                    }
                                });
                                $("#accountRegisterForm .effectiveWorkTime").addClass("form-required").addClass("form-required-7");
                                $("#accountRegisterForm").bootstrapValidator("addField","effectiveWorkTime",{
                                    validators: {
                                        notEmpty: {
                                            message: '日有效工时不能为空'
                                        },
                                        regexp: {
                                            regexp:  /^[0-9]+\.?[0-9]{0,2}$/,
                                            message: '数字保留两位小数'
                                        }
                                    }
                                });

                            
                            }
                           
                            if(_data.equipType=='2'){
                            	$("#accountRegisterForm").find("input[name=equipType]").val('环境类');
                            	$(".aidEquipCodes").attr("disabled",true);
                            	$(".effectiveWorkTime").attr("disabled",true);
                            }
                            if(_data.equipType=='3'){
                            	$("#accountRegisterForm").find("input[name=equipType]").val('能源类');
                            	$(".aidEquipCodes").attr("disabled",true);
                            	$(".effectiveWorkTime").attr("disabled",true);
                            }
                            if(_data.equipType=='4'){
                            	$("#accountRegisterForm").find("input[name=equipType]").val('检测类');
                            	$(".aidEquipCodes").attr("disabled",true);
                            	$(".effectiveWorkTime").attr("disabled",true);
                            }
                            if(_data.equipType=='5'){
                            	$("#accountRegisterForm").find("input[name=equipType]").val('生产辅助类');
                            	$(".aidEquipCodes").attr("disabled",true);
                            	$(".effectiveWorkTime").attr("disabled",true);
                            }
                            
                            if(_data.equipType="1"){//生产类
                            	
                            	var aidSelect =equipInfoInit._aidEquipSelect(_data.equipCode);
                            	debugger;
                            	if(_data.aidEquips) {
                            		for(var i=0;i<_data.aidEquips.length;i++){
                            			 var option = new Option(
                            					 _data.aidEquips[i].aidEquipName,
                            					 _data.aidEquips[i].aidEquipCode,true,true);
                            			 aidSelect.append(option);
                            		}
                            		aidSelect.trigger("change");
                                }
                            	
                            }
                            
                            $("#accountRegisterForm").find("input[name=effectiveWorkTime]").val(_data.effectiveWorkTime);
                            $("#accountRegisterForm").find("select[name=factory]").val(_data.factoryId);
                            $("#accountRegisterForm").find("select[name=shop]").val(_data.shopId);
                            $("#accountRegisterForm").find("select[name=line]").val(_data.lineId);
                            $("#accountRegisterForm").find("select[name=location]").val(_data.locationId);
                            $("#accountRegisterForm").find("input[name=installLocation]").val(_data.installLocation);
                            
                          //投产日期
                            $("#accountRegisterForm").find("input[name=productionDate]").val(_data.productionDate);
                            //使用年限
                           $("#accountRegisterForm").find("input[name=expectedYear]").val(_data.expectedYear);
                           
                            //设备状态
                           /*$("#accountRegisterForm").find("select[name=equipStatus]").find("option[value='"+_data.equipStatus+"']").attr("selected",true);
                           $("#accountRegisterForm").find("select[name=equipStatus]").trigger("change");*/
                           
                           if(typeof(_data.equipStatus)=="undefined"){
                        	   $("#accountRegisterForm").find("select[name=equipStatus]").val(1);
                           }else{
                        	   $("#accountRegisterForm").find("select[name=equipStatus]").val(_data.equipStatus);
                           }
                           
                            
                            
                            $("#accountRegisterForm").find("input[name=pkId]").val(_data.pkId);
                            //初始化用户
                            var userId = _data.responsiblePersonId;
                            var userName = _data.responsiblePerson;
                            if(userId!=null&&userName!=null) {
                                var option = new Option(userName,userId,true,true);
                                userSelect2.append(option);
                                userSelect2.trigger("change");
                            }
                        }
                    },
                    error :function() {
                        DialogUtil.error("系统繁忙！");
                    }
                });

                $("#myModal .title").html("台账登记");
                $("#myModal .yes").attr("disabled",false);
                $("#accountRegisterForm .line").removeClass("form-required");
                $("#accountRegisterForm .line").removeClass("form-required");
                $('#myModal').modal();
            });
        },
        //表单校验
        _validatorForm : function () {
            $("#accountRegisterForm").bootstrapValidator({
                message: 'This value is not valid',
                live: 'submitted',
                excluded:[":disabled"],
                fields: {/*验证*/
                    equipCode: {
                        message: '设备编码无效',
                        validators: {
                            notEmpty: {
                                message: '设备编码'
                            }
                        }
                    },
                    equipName: {
                        message: '设备名称无效',
                        validators: {
                            notEmpty: {
                                message: '设备名称不能为空'
                            },
                            stringLength: {
                                max: 20,
                                message: '工序名称长度不能超过20个字符'
                            }
                        }
                    },
                    supplier: {
                        message: '供应商无效',
                        validators: {
                            notEmpty: {
                                message: '供应商不能为空'
                            }
                        }
                    },
                    operation: {
                        message: '工序无效',
                        validators: {
                            notEmpty: {
                                message: '工序不能为空'
                            }
                        }
                    },
                    equipModel: {
                        message: '设备型号无效',
                        validators: {
                            notEmpty: {
                                message: '设备型号不能为空'
                            }
                        }
                    },
                    equipType: {
                        message: '设备类别无效',
                        validators: {
                            notEmpty: {
                                message: '设备类别不能为空'
                            }
                        }
                    },
                    factory: {
                        message: '厂区无效',
                        validators: {
                            notEmpty: {
                                message: '厂区不能为空'
                            }
                        }
                    },
                    location: {
                        message: '区域无效',
                        validators: {
                            notEmpty: {
                                message: '区域不能为空'
                            }
                        }
                    },
                    responsiblePerson: {
                        message: '责任人无效',
                        validators: {
                            notEmpty: {
                                message: '责任人不能为空'
                            }
                        }
                    },
                    expectedYear: {
                        message: '使用年限无效',
                        validators: {
                            notEmpty: {
                                message: '使用年限不能为空'
                            },
                            numeric: {message: '使用年限只能输入数字'}
                        }
                    },
                    productionDate: {
                        message: '投产日期无效',
                        trigger:"change",
                        validators: {
                            notEmpty: {
                                message: '投产日期不能为空'
                            }
                        }
                    }

                }
            });
        },
        _initEquipTypeChange : function () {
            $(".equipType").on("change",function () {
                //debugger
                if("2"===$(".equipType").val()) {
                    $("#accountRegisterForm .shop").addClass("form-required");
                    $("#accountRegisterForm").bootstrapValidator("addField","shop",{
                        validators: {
                            notEmpty: {
                                message: '车间不能为空'
                            }
                        }
                    });
                    $("#accountRegisterForm .line").addClass("form-required");
                    $("#accountRegisterForm").bootstrapValidator("addField","line",{
                        validators: {
                            notEmpty: {
                                message: '产线不能为空'
                            }
                        }
                    });
                    $("#accountRegisterForm .effectiveWorkTime").addClass("form-required").addClass("form-required-7");
                    $("#accountRegisterForm").bootstrapValidator("addField","effectiveWorkTime",{
                        validators: {
                            notEmpty: {
                                message: '日有效工时不能为空'
                            },
                            regexp: {
                                regexp:  /^[0-9]+\.?[0-9]{0,2}$/,
                                message: '数字保留两位小数'
                            }
                        }
                    });

                } else {
                    $("#accountRegisterForm").data('bootstrapValidator').destroy();
                    $("#accountRegisterForm .shop").removeClass("form-required");
                    //$("#accountRegisterForm").bootstrapValidator("removeField","shop");
                    $("#accountRegisterForm .line").removeClass("form-required");
                    $("#accountRegisterForm .effectiveWorkTime").removeClass("form-required").removeClass("form-required-7");
                    //$("#accountRegisterForm").bootstrapValidator("removeField","line");
                    equipInfoInit._validatorForm();
                }

            });
        },
        //保存
        _save : function () {
            $("#myModal .yes").on("click",function (e) {
                e.preventDefault();
                $("#accountRegisterForm").data("bootstrapValidator").validate();
                var flag = $("#accountRegisterForm").data("bootstrapValidator").isValid();
                if(!flag){
                    //未通过验证
                    return false;
                }
                $("#myModal .yes").attr("disabled",true);
                var entity = {};
                entity['pkId'] = $("#accountRegisterForm").find("input[name=pkId]").val();
                entity['equipCode'] = $("#accountRegisterForm").find("input[name=equipCode]").val();
                /*entity['equipType'] = $("#accountRegisterForm").find("select[name=equipType]").val();*/
                //辅助类设备
                entity['aidEquipCodes'] =$(".aidEquipCodes").val().toString();
                
                entity['effectiveWorkTime'] = $("#accountRegisterForm").find("input[name=effectiveWorkTime]").val();
                entity['factoryId'] = $("#accountRegisterForm").find("select[name=factory]").val();
                entity['shopId'] = $("#accountRegisterForm").find("select[name=shop]").val();
                entity['lineId'] = $("#accountRegisterForm").find("select[name=line]").val();
                entity['locationId'] = $("#accountRegisterForm").find("select[name=location]").val();
                entity['installLocation'] = $("#accountRegisterForm").find("input[name=installLocation]").val();
                entity['responsiblePerson'] = $("#accountRegisterForm").find("select[name=responsiblePerson]").val();
                
                //投产日期
                entity['productionDate'] = $("#accountRegisterForm").find("input[name=productionDate]").val();
                //使用年限
                entity['expectedYear'] = $("#accountRegisterForm").find("input[name=expectedYear]").val();
                //设备状态
                entity['equipStatus'] = $("#accountRegisterForm").find("select[name=equipStatus]").val();
                
                
                $.ajax({
                    url : ctx + '/equipment/account/saveOrUpdateEquipInfo/save.mvc',
                    type : "post",
                    dataType : 'json',
                    data : entity,
                    success : function(response) {
                        if (response.result === true) {
                            DialogUtil.ok("保存成功");
                            //取消
                            $('#myModal').modal('hide');
                            $('#equipInfoTable').bootstrapTable('refresh');
                        } else {
                            DialogUtil.error(response.message);
                        }
                        $("#myModal .yes").attr("disabled",false);

                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        $("#myModal .yes").attr("disabled",false);
                        console.log(errorThrown);
                        DialogUtil.error("系统错误");
                    }
                });

            });
        },
        _initFactorySelect : function () {
            $.ajax({
                url: ctx +'/factory/factoryArea/listAllFactory/get.mvc',
                type:"post",
                aysnc: false,
                dataType:'json',
                data : '',
                success : function(data){
                    $("#accountRegisterForm select[name=factory]").append("<option value='' >请选择</option>");
                    for (var i = 0; i < data.length; i++) {
                        $("#accountRegisterForm select[name=factory]").append("<option value='"+data[i].pkId+"' >" + data[i].factoryName + "</option>");
                    }
                },
                error: function(){
                    alert("系统错误");
                }
            });
        },
        _initLineSelect : function () {
            $.ajax({
                url: ctx +'/factory/product/listAllProduct/get.mvc',
                type:"post",
                aysnc: false,
                dataType:'json',
                data : '',
                success : function(data){
                    $("#accountRegisterForm select[name=line]").append("<option value=''>请选择</option>");
                    for (var i = 0; i < data.length; i++) {
                        $("#accountRegisterForm select[name=line]").append("<option value='"+data[i].pkId+"' >" + data[i].lineName + "</option>");
                    }
                },
                error: function(){
                    alert("系统错误");
                }
            });
        },
        _initShopSelect : function () {
            $.ajax({
                url: ctx +'/factory/shop/listAllShopsByFactoryId/get.mvc',
                type:"post",
                aysnc: false,
                dataType:'json',
                success : function(response){
                    if(response.result === true) {
                        var _data = response.data;
                        $("#accountRegisterForm select[name=shop]").append("<option value='' >请选择</option>");
                        for (var i = 0; i < _data.length; i++) {
                            $("#accountRegisterForm select[name=shop]").append("<option value='"+_data[i].pkId+"' >" + _data[i].shopName + "</option>");
                        }
                    } else {
                        DialogUtil.error(response.message);
                    }

                },
                error: function(){
                    alert("系统错误2");
                }
            });
        },
        _initAreaSelect : function () {
            $.ajax({
                url: ctx +'/factory/area/listAllArea/get.mvc',
                type:"post",
                aysnc: false,
                dataType:'json',
                data : '',
                success : function(response){
                    if(response.result === true) {
                        var _data = response.data;
                        $("#accountRegisterForm select[name=location]").append("<option value='' >请选择</option>");
                        for (var i = 0; i < _data.length; i++) {
                            $("#accountRegisterForm select[name=location]").append("<option value='"+_data[i].pkId+"' >" + _data[i].areaName + "</option>");
                        }
                    } else {
                        DialogUtil.error(response.message);
                    }
                },
                error: function(){
                    alert("系统错误");
                }
            });
        },
        _modalHidden : function () {
            //模态框消失清空信息
            $("#myModal").on("hide.bs.modal",function(e){
                $('#myModal input').each(function() {
                    if ($(this).val() !== "" || $(this).prop('checked') === true) {
                        $(this).val("").prop('checked', false);
                    }
                });
                $("#myModal select").each(function () {
                    if($(this).hasClass('systemUserSearch')
                    		||$(this).hasClass('aidEquipCodes')) {
                        $(this).val(null).trigger("change");
                        //清除option
                        $(this).find("option").remove();
                    } else {
                        $(this).val("");
                    }
                    
                });
                
                
                $("#myModal select option").each(function(){
                	$(this).attr("selected",false);
                })
                
                $('.aidEquipCodes').val(null).trigger('change');
                $('.aidEquipCodes').select2('destroy');
            	$('.line').removeClass('form-required', 'form-required-4');
            	$('.shop').removeClass('form-required', 'form-required-4');
            	$("#accountRegisterForm").data('bootstrapValidator').destroy();
            	equipInfoInit._validatorForm();
                $('#accountRegisterForm').bootstrapValidator('resetForm', false);
            });
        },
        _aidEquipSelect : function(equipCode){
            var select2 = $(".aidEquipCodes").select2({
                ajax: {
                    url: ctx +'/equipment/account/searchEquipByType/get.mvc',
                    dataType: 'json',
                    data: function (params) {
                        var query = {
                            search: params.term,
                            equipCode: equipCode,
                            num: params.page || 1,
                            size:10
                        };
                        return query;
                    },
                    processResults: function (result) {
                        var opArr =new Array();
                        for ( var i = 0; i < result.data.length; i++) {
                            var obj = new Object();
                            obj.id=result.data[i].equipCode;
                            obj.text=result.data[i].equipName;
                            opArr.push(obj);
                        }
                        var result = {
                            results: opArr,
                            pagination :{
                                more:result.result
                            }
                        };
                        
                        return result;
                    },
                    cache: true
                },
                placeholder: '请选择',
                language: "zh-CN",
                escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
                minimumInputLength: 0
            });
            //删除后后台清除辅助类设备
            $(".aidEquipCodes").off('select2:unselect').on("select2:unselect", function(e) { 
            	var aidEquipCode=e.params.data.id;
            	debugger;
            	$.ajax({
                    url: ctx +'/equipment/account/delAidEquip/del.mvc',
                    type:"post",
                    aysnc: false,
                    dataType:'json',
                    data : {equipCode:equipCode,aidEquipCode:aidEquipCode},
                    success : function(response){
                        if(response.result != true) {
                            DialogUtil.error(response.message);
                        }
                    },
                    error: function(){
                        alert("系统错误");
                    }
                });
            	
            });
            return select2;
        }
    }
}();